extern	cursor

        ;; This function is copied from Orange'S. And I commented it.
        
        ;; I think it unnecessary to impl my own vedio operation func.
        
[section .text]

global	print_asm
        
print_asm:
        push	ebp
	mov	ebp, esp

	mov	esi,    [esp+8]	        ; str 
	mov	edi,    [cursor]
	mov	ah,     [esp+12]	; color
.read_char_from_mem_2_video:
	lodsb
	test	al, al                  ;if al = "\0",ret
	jz	.end
	cmp	al, 0Ah	                ;if al = "\n",change edi to next line beginning
	jnz	.move_char_2_video_memory
	push	eax
	mov	eax, edi
	mov	bl, 160
	div	bl
	and	eax, 0FFh
	inc	eax
	mov	bl, 160
	mul	bl
	mov	edi, eax
	pop	eax
	jmp	.read_char_from_mem_2_video
.move_char_2_video_memory:
	mov	[gs:edi], ax
	add	edi, 2
	jmp	.read_char_from_mem_2_video
.end:
	mov	[cursor], edi
	pop	ebp
	ret
